﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectHT.YKDGVB2012.Core.Webpage
{
    public class ContentLoader : Page
    {
        protected Panel paneloader;
        protected void Page_Load(object sender, EventArgs e)
        {
            var rots = String.Format("{0}", Context.Request.Params[Helper.Constans.ROTS]);

            if (!String.IsNullOrEmpty(rots))
            {
                switch (rots)
                {
                    case "crm":
                        LoadMainCon(Context);
                        break;
                    case "cmmr":
                        LoadComment(Context);                        
                        break;



                }




            }


        }

        private void LoadComment(HttpContext context)
        {
            var edm = String.Format("{0}", Context.Request.Params[Helper.Constans.EDITMOD]);
            if (!String.IsNullOrEmpty(edm))
            {
                switch (edm)
                {
                    case "1":
                        LoadEditFormComment();
                        break;                  
                }

            }
        }

        private void LoadEditFormComment()
        {
            Control crtl = Page.LoadControl(@"/_CONTROLTEMPLATES/YkiendgDTLuat/Admin/EditComment.ascx");
            paneloader.Controls.Add(crtl);

        }

        private void LoadMainCon(HttpContext context)
        {
            var edm = String.Format("{0}", Context.Request.Params[Helper.Constans.EDITMOD]);
            if (!String.IsNullOrEmpty(edm))
            {
                switch (edm)
                {
                    case "0":
                        LoadCreateForm();
                        break;
                    case "1":
                        LoadCreateForm();
                        break;
                }

            }
        }

        private void LoadCreateForm()
        {
            Control crtl = Page.LoadControl(@"/_CONTROLTEMPLATES/YkiendgDTLuat/Admin/CreateNew.ascx");
            paneloader.Controls.Add(crtl);
        }
    }
}